<template>
	<div>
		<div class="publish-top">
			<div class="left-icon" @click="handleBack"> 
				<img src="../../../assets/images/left.png"/>
			</div>
			<p>我的关注</p>
		</div>
		<div class="my-follow">我的关注</div>
		<div class="follow-content">
			<ul class="follow-list" v-if="isFollowsxa">
				<li v-for="(item,index) in list" @click="onMaskent(item.user_id)">
					<div class="follow-img">
						<img :src="item.user_himg"/>
					</div>
					<div class="follow-information">
						<p class="name">{{item.user_nickname}}</p>
						<p class="autograph">{{item.user_desc}}</p>
					</div>
					<div class="not-follow" @click.stop="handleNot(item.user_id,index)">取消关注</div>
				</li>
			</ul>
			<div class="list-img-pic" v-else>
				<nocontent></nocontent>
			</div>
		</div>
		<!-------------------------遮罩---------------------------------------------------->
		<div class="mask" v-if="isShow">
			<div class="mask-opaciy"></div>
			<div class="mask-information">
				<img :src="isfocusData.user_himg" class="head-portrait"/>
				<img src="../../../assets/images/home/del.png" class="Close" @click="onClose"/>
				<h3>{{isfocusData.user_nickname}}</h3>
				<p>{{isfocusData.user_desc}}</p>
			</div>
		</div>
	</div>
</template>

<script>
	import axios from "axios";
	import user from '../../../utils/isLogin';
	import Nocontent from '@/components/home/no-content';
	import qs from 'qs';
	export default{
		data(){
			return{
				list:[],
				isShow:false,
				isfocusData:[],
				value:'',
				isFollowsxa:true
			}
		},
		filters: {
		  url: function (value) {
		    if (!value) return ''
		    value = user.src + value
		    return value
		  }
		},
		created(){
			let plusReady = ()=>{
				
			}
			if (window.plus) {
		     plusReady();
		   } else {
		     document.addEventListener("plusready", plusReady, false);
		   }
		    
			var userId = JSON.parse(window.localStorage.getItem( 'userInfo' )).userId;

	    	axios.post(user.src+ '/index/collect/focus_list' , {
				userid: userId,
			})
			.then((res)=> {
				
				if(res.data.status == 1056){
					this.isFollowsxa = false;
				}
				if(res.data.status == 200){
					this.list = res.data.data;
					this.isFollowsxa = true;
				}
			})
			.catch((error)=> {
			   
			});
		},
		components:{
			Nocontent
		},
		methods:{
			//点击头像打开弹框
			onMaskent(id){
				this.isShow = true;
				var userId = JSON.parse(window.localStorage.getItem( 'userInfo' )).userId;
				var data = qs.stringify({
			   	articleUserid:id,
			   	userId:userId
				})
				axios({
				   method: 'post',
				   url: user.src + '/index/user/is_focus',
				   data:data
				})
				.then((res) => {
					if(res.data.status == 200){
						this.isfocusData = res.data.data;
						if(res.data.data.focus == 1){
							this.value = '已关注';
						}else{
							this.value =  '关注';
						}
					}
				})
				.catch((error)=> {
				    console.log(error);
				});
			},
			//关闭窗口
			onClose(){
				this.isShow = false;
			},
			handleBack(){
				var follow = plus.webview.currentWebview();
				plus.webview.close(follow);
			},
			handleNot(id,index){
				var userId = JSON.parse(window.localStorage.getItem( 'userInfo' )).userId;
				var data = qs.stringify({
					userid:userId,
				   article_userId:id
				})
				axios({
				   method: 'post',
				   url: user.src + '/index/collect/focus',
				   data:data
				})
			   .then(res => {
		   		if(res.data.status == 1030){
		   			this.list.splice(index, 1);
					}
			   })
			   .catch(err => {
			      console.log(err)
			   })
			}
		} 
	}
</script>

<style lang='less' scoped>

html,body{
	padding: 0;
	margin: 0;
	width: 100%;
	height: 100%;
	background: #f6f6f6;
}
*{
	margin: 0;
	padding: 0;
}
ul,li{
	list-style: none;
}
.publish-top{
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 60px;
	background:@default-blue;
	box-shadow: 0px 0px 8px 1px #999;
	padding-top: 70px;
	display:flex;				
	.left-icon{
		width: 90px;			
		img{
			width: 15px;
			height: 26px;
			margin-left: 31px;
		}
	}
	p{		
		width: 80%;
		color: #fff;
		font-size: 28px;
		text-align: center;
	}
	span{
		display: block;
		width: 170px;
		color: #fff;
		font-size: 28px;
		text-align: center;
	}
}	
.my-follow{
	padding-top: 130px;
	padding-left: 26px;
	height: 62px;
	line-height: 62px;
	font-size: 26px;
	color: #666;
	background: #f6f6f6;
}
.follow-content{
	width: 100%;		
	.follow-list{
		padding: 0 28px;			
		li{
			padding: 34px 0 20px 0;
			border-bottom: 1px solid #eeeeee;
			overflow: hidden;				
			.follow-img{
				float: left;
				width: 90px;
				height: 90px;
				border-radius: 50%;
				img{
					display: block;
					width: 90px;
					height: 90px;
					border-radius: 50%;
				}				
			}				
			.follow-information{
				float: left;
				padding: 14px 0 0 24px;
				.name{
					margin-bottom: 16px;
					line-height: 26px;
					font-size: 26px;
					font-weight: bold;
					color: #333;
				}
				.autograph{
					width: 300px;
					line-height: 22px;
					font-size: 22px;
					color: #666;
					overflow:hidden;
					text-overflow:ellipsis;
					display:-webkit-box;
					-webkit-box-orient:vertical;
					-webkit-line-clamp:2;
				}
			}
			.not-follow{
				float: right;
				width: 140px;
				height: 40px;
				text-align: center;
				line-height: 40px;
				font-size: 24px;
				color: #FFFFFF;
				border-radius: 30px;
				background: #00a2ff;
				margin-top: 20px;
				margin-right: 21px;
			}
		}
	}
}
/*-----------------遮罩------------------------*/
	.mask{
		width: 100%;
		height: 100%;
		position: fixed;
		left: 0;
		top: 0;
		.mask-opaciy{
			width: 100%;
			height: 100%;
			background: #000000;
			opacity: .5;
		}
		.mask-information{
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			margin: auto;
			width: 598px;
			height: 400px;
			border: 0.1rem solid #d4ccca;
			background: #FFFFFF;
			border-radius: 10px;
			.head-portrait{
				position: absolute;
				left: 212px;
				top: -70px;
				width: 160px;
				height: 160px;
				border: 0.2rem solid #FFFFFF;
				border-radius: 50%;
			}
			.Close{
				position: absolute;
				right: 0;
				top: -80px;
				width:76px;
				height: 76px;
			}
			h3{
				margin-top: 123px;
				text-align: center;
				font-size: 38px;
			}
			p{
				height: 147px;
				margin-top: 10px;
				padding: 0 80px;
				font-size: 26px;
				overflow: hidden;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 3;
				overflow: hidden;
			}
			.info-follow{
				height: 128px;
				border-top: 0.1rem solid #cecece;
				display: flex;
				align-items: center;	
				justify-content: space-between;			
				padding-left: 90px;
				padding-right: 75px;
				div{
					display: flex;
					align-items: center;
					img{
						width: 48px;
						height: 46px;
						margin-right: 10px;
					}
					span{
						font-size: 28px;
					}
				}
				img{
					width: 1px;
					height: 43px;
				}
				
			}
		}
	}
	.list-img-pic{
		height: 800px;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>